* CONJOINT ANALYSIS
* Reshape data for conjoint

rename sponsor1 sp_spon1
rename sponsor2 sp_spon2
rename sponsor3 sp_spon3

rename mode1 sp_mode1
rename mode2 sp_mode2
rename mode3 sp_mode3

rename timing1 sp_tim1
rename timing2 sp_tim2
rename timing3 sp_tim3

rename topic1 sp_top1
rename topic2 sp_top2
rename topic3 sp_top3

rename surveyvig1 vig1
rename surveyvig2 vig2
rename surveyvig3 vig3

reshape long sp_spon sp_mode sp_tim sp_top vig, i(caseid) j(contest_no) 

replace vig = . if vig<0
revrs vig, replace

gen sp_timing2 = 1 if sp_tim==2
replace sp_timing2 = 1 if sp_tim==3
replace sp_timing2 = 2 if sp_tim==4
replace sp_timing2 = 2 if sp_tim==1


* Tables A4 and A6i-iii
* Effect of survey attributes and atttiudes on participation intentions
* Qatari
reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor intentionsfactor if region3==0 [aweight=wgt], cluster(caseid)

* Arab non-Qatari
reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor intentionsfactor if region3==1 [aweight=wgt], cluster(caseid)

* Non-Arab
reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor intentionsfactor if region3==2 [aweight=wgt], cluster(caseid)

* Table 5
* For marginal effects (change from -1 to +1 SD) and associated confidence 
margins, at(enjoyfactor=(-1 1)) post coefleg
test _b[1bn._at] =_b[2._at]

* And so on for other attitude dimensions and groups

* Table A5: Group differences in attribute treatment effects
reg vig ib2.sp_mode##i.region3 i.sp_timing2##i.region3 ib2.sp_top##ib1.region3 i.sp_spon##i.region3 [aweight=wgt], cluster(caseid)
margins, dydx(sp_top) by(rb0.region3)
* And so on for other survey attributes and group combinations

* Figure 2
* Effect of Intentions on Participation (conjoint), by topic

* Intentions by sponsor
* Qatari
quietly: reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==0, cluster(caseid)
margins, dydx(intentionsfactor) by(sp_spon)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "University" 2 "Government" 3 "Company" 4 "International Org.                    ") ylabel(-.3 -.2 -.1 0 .1 .2, grid) yscale(range(-.3 .2)) plot1opts(msymbol(Oh)) title("Qatari") xtitle("Sponsor") ysize(2)

* Arab non-Qatari
quietly: reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==1 [aweight=wgt], cluster(caseid)
margins, dydx(intentionsfactor) by(sp_spon)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "University" 2 "Government" 3 "Company" 4 "International Org.                    ") ylabel(-.3 -.2 -.1 0 .1 .2, grid) yscale(range(-.3 .2)) plot1opts(msymbol(Oh)) title("Arab non-Qatari") xtitle("Sponsor") ysize(2)

* Non-Arab
quietly: reg vig ib2.sp_mode i.sp_timing2 ib2.sp_top i.sp_spon##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==2 [aweight=wgt], cluster(caseid)
margins, dydx(intentionsfactor) by(sp_spon)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "University" 2 "Government" 3 "Company" 4 "International Org.                    ") ylabel(-.3 -.2 -.1 0 .1 .2, grid) yscale(range(-.3 .2)) plot1opts(msymbol(Oh)) title("Non-Arab") xtitle("Sponsor") ysize(2)

* Figure 3
* Figures for Effect of Integrity on Participation (conjoint), by topic

* Qatari
quietly: reg vig ib2.sp_mode i.sp_timing2 i.sp_spon ib2.sp_top##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==0 [aweight=wgt], cluster(caseid)
margins, dydx(intentionsfactor) by(sp_top)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "Economic" 2 "Cultural" 3 "Political") ylabel(-.3 -.2 -.1 0 .1, grid) yscale(range(-.3 .1)) plot1opts(msymbol(Oh)) title("Qatari") xtitle("Topic") ysize(2)

* Arab non-Qatari
quietly: reg vig ib2.sp_mode i.sp_timing2 i.sp_spon ib2.sp_top##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==1 [aweight=wgt], cluster(caseid)
margins, dydx(intentionsfactor) by(sp_top)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "Economic" 2 "Cultural" 3 "Political") ylabel(-.3 -.2 -.1 0 .1, grid) yscale(range(-.3 .1)) plot1opts(msymbol(Oh)) title("Arab non-Qatari") xtitle("Topic") ysize(2)

* Non-Arab
quietly: reg vig ib2.sp_mode i.sp_timing2 i.sp_spon ib2.sp_top##c.intentionsfactor enjoyfactor valuefactor reliabilityfactor costsfactor privacyfactor if region3==2 [aweight=wgt], cluster(caseid)
margins, dydx(intentionsfactor) by(sp_top)
marginsplot, recast(scatter) scheme(s1mono) yline(0, lpattern(dash)) ytitle("Change in E[Survey Participation]") xlabel(1 "Economic" 2 "Cultural" 3 "Political") ylabel(-.3 -.2 -.1 0 .1 .2, grid) yscale(range(-.3 .1 .2)) plot1opts(msymbol(Oh)) title("Non-Arab") xtitle("Topic") ysize(2)

* Table A7: Group differences in attitude effects
reg vig ib2.sp_mode##i.region3 i.sp_timing2##i.region3 ib2.sp_top##i.region3 i.sp_spon##i.region3 c.enjoyfactor##i.region3 c.valuefactor##i.region3 c.reliabilityfactor##i.region3 c.costsfactor##i.region3 c.privacyfactor##i.region3 c.intentionsfactor##i.region3 [aweight=wgt], cluster(caseid)
margins, dydx(reliabilityfactor) by(rb0.region3)
* And so on for other attitude dimensions and group combinations
